package com.bw.lib_internet

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

/**
 *@ClassName RetrofitUtils
 *@Author hu..
 *@Data 2024/7/21
 *@Description
 *              OkHttpClient+Retrofit
 */
object RetrofitUtils {
    fun getRetrofit(): Retrofit{
        val okHttpClient = OkHttpClient.Builder()
            .readTimeout(30,TimeUnit.SECONDS)
            .writeTimeout(30,TimeUnit.SECONDS)
            .callTimeout(30,TimeUnit.SECONDS)
            .connectTimeout(30,TimeUnit.SECONDS)

        val retrofit = Retrofit.Builder()
            .client(okHttpClient.build())
            .baseUrl("http://10.161.9.80:7015/")
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())

        return retrofit.build()
    }
}